#include <QtCore/QCoreApplication>

#include <ace/INET_Addr.h>
#include <ace/SOCK_Acceptor.h>
#include <ace/Handle_Set.h>
#include <ace/Signal.h>
#include <signal.h>
#include "tetrixserver.h"

#include "../tools/iniparser.h"
#include "protosrvmanager.h"
#include "createroomreq.h"
#include "createroomresp.h"
#include "getroomlistreq.h"
#include "getroomlistresp.h"
#include "enterroomsrv.h"
#include "leaveroomreq.h"
#include "statussetreq.h"

void registerAllProtoSrv()
{
    ProtoSrvManager::getInstance()->registerProtoSrv(new CreateRoomReq());
    ProtoSrvManager::getInstance()->registerProtoSrv(new GetRoomListReq());
    ProtoSrvManager::getInstance()->registerProtoSrv(new EnterRoomReq());
    ProtoSrvManager::getInstance()->registerProtoSrv(new LeaveRoomReq());
    ProtoSrvManager::getInstance()->registerProtoSrv(new StatusSetReq());
}

void my_signal_handler(int signo)
{
    if(signo == SIGINT)
        TetrixServer::getInstance()->stop();
}

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    ACE_Sig_Action sa(SIGINT,my_signal_handler);

    registerAllProtoSrv();

    TetrixServer::getInstance()->run(argc,argv);

    return 0;/*a.exec()*/;
}
